package com.sky.aspect;


import cn.hutool.core.date.DateTime;
import com.sky.annotation.AutoFill;
import com.sky.context.BaseContext;
import com.sky.enumeration.OperationType;
import com.sky.mapper.EmployeeMapper;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Aspect
@Component
@Slf4j

public class OperationLogAspect {

    @Pointcut("@annotation(com.sky.annotation.OperationLog)")
    public void operationLogPointCut(){
    }

    @Autowired
    public EmployeeMapper employeeMapper;




    @Around("operationLogPointCut()")
    public void  operationLog(JoinPoint joinPoint){



        DateTime dateTime = new DateTime();


        Long currentId = BaseContext.getCurrentId();
        String name = new String();

        name =employeeMapper.getNameById(currentId);
        //方法签名对象
        String methodName = joinPoint.getSignature().getName();


        log.info("操作人"+name+"在"+dateTime+"执行了方法"+methodName);







    }

}
